package com.wzy.jpademo1.service;

import com.wzy.jpademo1.dao.StudentRepository;
import com.wzy.jpademo1.pojo.Student;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class StudentService {
    @Resource
    private StudentRepository studentRepository;

    public Student getStuByName(String name){
        return studentRepository.findByName(name);
    }

    public List<Student> getStusByNameAndAddress(String name,String address){
        return studentRepository.findByNameAndAddress(name,address);
    }

    public List<Student> getStusByNameLike(String name){
        return studentRepository.findByNameLike("%"+name+"%");
    }

    public void saveAll(List<Student> students){
        studentRepository.saveAll(students);
    }
}
